<?php /* Smarty version Smarty 3.1.4, created on 2012-05-01 10:54:42
         compiled from ".\templates\product\homepageproduct.tpl" */ ?>
<?php /*%%SmartyHeaderCode:167624f9fc0f257cc81-79092838%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '2dc1dcdd39adb9e4645aaf9d95e6c6b1813e755d' => 
    array (
      0 => '.\\templates\\product\\homepageproduct.tpl',
      1 => 1334484556,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '167624f9fc0f257cc81-79092838',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'title' => 0,
    'itemcodearr' => 0,
    'siteurl' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty 3.1.4',
  'unifunc' => 'content_4f9fc0f281747',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_4f9fc0f281747')) {function content_4f9fc0f281747($_smarty_tpl) {?><script type="text/javascript">
$(function() {
        $("#home-products").sortable({
            update: function(event, ui) {
            $.post("controller.php?task=sorthomepage",{ products: $('#home-products').sortable('serialize')} );
         }
});
    	$( "#sortable" ).disableSelection();
});

    function addhomepageproduct(){
           var txtitemcode = $("#txtitemcode").val();
         if(txtitemcode=='')
             {
                     alert("Item code cannot be empty");
                     $("#txtitemcode").focus();
                     return false;
             }

          $("#loader_area").show();
		$("#loader_area").html('<img src="images/shared/loader.gif" /> loading...');
		$.ajax({
		type: "POST",
		url: 'controller.php?task=addhomepageproduct',
                data: ({itemcode:txtitemcode }),
    	success: function(data, textStatus, XMLHttpRequest){
    	   	if(data != '') {
                   if(data!='F')
                       {
                       alert("successfully updated the home page products");
                        $("#message_area").show();
	    	   	$("#message_area").html(data);
                      loadPage('product/homepageproduct');
                      }
                    else{
                          alert("Item code not exist or product id out of stock ");
                          loadPage('product/homepageproduct');
                    }
    	   	}
    	},
    	complete: function complete(XMLHttpRequest, textStatus){
            //$("#loader_area").hide();
        }
	});
}
function deletehomepageproduct(productid)
{
	var msg = confirm("Are you sure you want to remove this product from the homepage");
	if (msg){
		$.ajax({
			type: "POST",
			url: 'controller.php?task=deletehomepageproduct',
			data: ({productid: productid}),
	    	success: function(data, textStatus, XMLHttpRequest){
	    	   	if(data != '') {
                             alert("successfully deleted the product");
	    			$("#message_area").html(data);
	    			loadPage('product/homepageproduct');
	    	   	}
	    	},
	    	complete: function complete(XMLHttpRequest, textStatus){
	            //$("#loader_area").hide();
	       }
		});
	} else {
		return false;
	}
}
</script>
<div id="page-heading">
	<h1><?php echo $_smarty_tpl->tpl_vars['title']->value;?>
</h1>         
</div>

<div id="page-heading">
	Item code  : <input onblur="" type="text" name="txtitemcode" id="txtitemcode"> <input onclick="addhomepageproduct()" type="button" value="add" id="add" name="add">
</div>

<ul id="home-products" class="ui-sortable">
	<?php if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1'])) unset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']);
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['name'] = 'sec1';
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] = is_array($_loop=$_smarty_tpl->tpl_vars['itemcodearr']->value) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = true;
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] = 1;
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop']-1;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
    $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
    if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] == 0)
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = false;
} else
    $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = 0;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']):

            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] = 1;
                 $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'];
                 $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration']++):
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['first']      = ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == 1);
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['last']       = ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total']);
?>
		<li id="product_<?php echo $_smarty_tpl->tpl_vars['itemcodearr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['productid'];?>
" class="ui-state-default">
                <span class="ui-icon ui-icon-arrowthick-2-n-s">
                </span>
         <img src="<?php echo $_smarty_tpl->tpl_vars['siteurl']->value;?>
/images/products/thumbs/<?php echo $_smarty_tpl->tpl_vars['itemcodearr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['filename'];?>
" border="0" width="75" height="75" >
       <strong><?php echo $_smarty_tpl->tpl_vars['itemcodearr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['product_title'];?>
</strong>
           <?php echo $_smarty_tpl->tpl_vars['itemcodearr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['itemcode'];?>

       <a  href="javascript: void(0);" onclick="deletehomepageproduct(<?php echo $_smarty_tpl->tpl_vars['itemcodearr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['productid'];?>
);"><img align="right" src="images/icons/a-minus.gif" /></a>
                </li>
	<?php endfor; endif; ?>
</ul>	<?php }} ?>